
#pragma once

#include <string>
#include <cocos2d.h>

using namespace std;

enum class MessageType {
	// ui layer
	play_game,
	pause_game,
	exit_gameplay,
	switch_game_speed,

	// tower menu layer
	create_soldier,
	call_next_wave,
	next_wave_began,
	show_wave_indicator,

	count
};

struct GameMessage {
	const char* sender;
	const char* receiver;
	MessageType key;

	string strValue;
	int intValue;
	int arrValues[8];
	cocos2d::Point ptValue;
	void* userData;

	GameMessage():
				sender(nullptr),
				receiver(nullptr),
				key(MessageType::count),
				intValue(0),
				ptValue(cocos2d::Point::ZERO),
				userData(nullptr)
	{
		memset(arrValues, 0, sizeof(arrValues));
	}

	GameMessage(const char* _sender,  const char* _receiver, MessageType k, const string& s):
				sender(_sender), receiver(_receiver), key(k), strValue(s), intValue(0), ptValue(cocos2d::Point::ZERO) {
		memset(arrValues, 0, sizeof(arrValues));
		userData = nullptr;
	}

	GameMessage(const char* _sender,  const char* _receiver, MessageType k, int i):
				sender(_sender), receiver(_receiver), key(k), intValue(i), ptValue(cocos2d::Point::ZERO) {
		memset(arrValues, 0, sizeof(arrValues));
		userData = nullptr;
	}

	GameMessage(const char* _sender,  const char* _receiver, MessageType k, void* p):
	sender(_sender), receiver(_receiver), key(k), intValue(0), ptValue(cocos2d::Point::ZERO) {
		memset(arrValues, 0, sizeof(arrValues));
		userData = p;
	}
};

class MessageHolder {
public:
	char* holderName;
	virtual void handleMessage() = 0;
};
